package br.ufrgs.tsp.model;

import java.util.LinkedList;
import java.util.List;

public class ModelFactory {
	
	private SequenceGenerator sequenceGenerator = new SequenceGenerator();
	
	/**
	 * Implements the singleton pattern (this centralizes the way that instances of this class are created).
	 * @return ModelFactory instance.
	 */
	public static ModelFactory getInstance() {
		return new ModelFactory();
	}
	
	public ICity createCity() {
		return new City(sequenceGenerator.getNextSequence(), new LinkedList<ICity>());
	}
	
	/**
	 * Creates an instance of a TSP Model object.
	 * @param cityId
	 * @return
	 */
	public ICity createCity(int cityId) {
		return new City(cityId, new LinkedList<ICity>());
	}
	
	/**
	 * 
	 * @param cityId
	 * @param neigbords
	 * @return
	 */
	public ICity createCity(int cityId, List<ICity> neigbords) {
		return new City(cityId, neigbords);
	}

	public void clear() {
		this.sequenceGenerator.clearSequences();
	}
}
